package Demo03.Demo05;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class BefferTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入信息");
        String next = sc.next();
        BufferedOutputStream out = null;
        try {
            out = new BufferedOutputStream(new FileOutputStream("G:\\a.txt"));
            byte[] bytes = next.getBytes();
            out.write(bytes,0,bytes.length);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                out.flush();
                if (out!=null)out.close();
            } catch (IOException e) {
                e.printStackTrace();

            }
        }
    }
}
